package com.hspedu.qqclient.service;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/3/17
 * @time 20:28
 * 该类管理客户端连接到服务器端的线程的类
 */
public class ManageClientConnectServerThread {
    /**
     * 用来保存线程的集合
     * key 就是用户 id
     * value 就是线程
     */
    private static ConcurrentHashMap<String,ClientConnectServerThread> hashMap = new ConcurrentHashMap<>();

    protected static ConcurrentHashMap<String,ClientConnectServerThread> getAllThreads(){
        return hashMap;
    }

    protected static void addClientConnectServerThread(String userId, ClientConnectServerThread thread){
        hashMap.put(userId,thread);
    }

    protected static ClientConnectServerThread getClientConnectServerThread(String userId){
        return hashMap.get(userId);
    }
}
